package com.shop.cereshop.commons.enums;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;

@Getter
@ApiModel(value = "PetTypeEnum", description = "宠物种类枚举")
public enum PetTypeEnum {

    @ApiModelProperty("猫")
    CAT(1, "猫"),

    @ApiModelProperty("狗")
    DOG(2, "狗"),

    @ApiModelProperty("鸟类")
    BIRD(3, "鸟类"),

    @ApiModelProperty("水族")
    AQUATIC(4, "水族"),

    @ApiModelProperty("其他")
    OTHER(5, "其他");

    private final Integer code;

    private final String message;

    PetTypeEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static String getMessage(Integer code) {
        for (PetTypeEnum petTypeEnum : PetTypeEnum.values()) {
            if (petTypeEnum.getCode().equals(code)) {
                return petTypeEnum.message;
            }
        }
        return "";
    }

    public static Integer getCode(String message) {
        for (PetTypeEnum petTypeEnum : PetTypeEnum.values()) {
            if (petTypeEnum.getMessage().equals(message)) {
                return petTypeEnum.code;
            }
        }
        return -1;
    }
}
